/**
 * 合同借阅列表
 * @author linfeng
 * @since 2019/12/24
 */
layui.define(['index', 'form', 'table', 'laypage', 'layedit','laydate'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var laypage = layui.laypage;
    var layedit = layui.layedit;

    form.render();

    table.init('zmn-table', {
        page: true,
        defaultToolbar: [''],
        limit: json.pageSize,
        height: 'full-149'
    });

    laypage.render(zmnPage.laypageOptions(json));

    // 2级部门联动
    form.on('select(deptOneId)', function(obj){
        triggerTwoDeptOptions(obj.value);
    })

    function triggerTwoDeptOptions(value){
        let twoDeptOptions = json.twoDepts.filter(p => p.parentId == value).map(p => {
            return p.deptId == json.vo.deptTwoId ? '<option value="'+p.deptId+'" selected="selected">'+p.deptName+'</option>' : '<option value="'+p.deptId+'">'+p.deptName+'</option>';
        });
        twoDeptOptions.unshift('<option value=""></option>');
        $('#deptTwoId').html(twoDeptOptions);
        form.render("select");
    }

    //对外暴露的接口
    exports('contract_borrow_record_list_js', {});
});

